<template>
  <div>
    <!-- 头部 -->
    <mt-header title="商品详情">
      <div slot="left">
        <mt-button @click="goBack" icon="back">返回</mt-button>
      </div>
    </mt-header>
    <!-- 主体 -->
    <div>
      <!-- 轮播 -->
      <mt-swipe :auto="4000">
        <mt-swipe-item v-for="item in bannerImg">
        <img :src="item.imgUrl"/>
        </mt-swipe-item>
      </mt-swipe>
      <!-- 轮播结束 -->
      <!-- 标题部分 -->
      <div class="top1">
        <div class="left">单反相机,彰显你的风格</div>
        <div class="right">
          <span class="mui-icon-extra mui-icon-extra-share"></span>
          <p>分享</p>
        </div>
      </div>
      <div style="clear:both"></div>
      <div class="down">
        <p>100000积分</p>
        <span>销量8件</span>
      </div>
      <!-- 标题结束 -->
      <!-- 详情评价 -->
      <div class="container">
        <ul>
          <li class="item">
            <a href="#">
              <span>  商品详情</span>
              <span class="mui-icon mui-icon-forward"></span>
            </a>
          </li>
          <li class="item">
            <a href="#">
              <span>商品评价</span>
              <span class="mui-icon mui-icon-forward"></span>
            </a>
          </li>
        </ul>
      </div>
      <!-- 详情评价结束 -->
      <!-- 加购按钮 -->
      <div class="btn">
        <ul class="clear">
          <li class="left_icon">
            <span class="mui-icon mui-icon-home-filled"></span>
            <p>商城</p>
          </li>
          <li class="left_icon">
            <span class="mui-icon mui-icon-chat"></span>
            <p>客服</p>
          </li>
          <li class="right_btn" @click="handleClick">
            <span class="cart">加入购物车</span>
          </li>
          <li class="right_btn" @click="jiazai()">
            <span class="pay">立即购买</span>
          </li>
        </ul>
      </div>
      <!-- 加购按钮结束 -->
      <!-- 模态框 -->
     <mt-popup class="model" v-model="popupVisible" position="bottom">
       <div class="top clear">
         <div class="top1">
           <img :src="require('../../assets/img/xj2.jpg')" alt="">
         </div>
         <div class="top2">
           <p>单反相机</p>
           <p>100000积分</p>
         </div>
         <div class="top3">
           <span class="mui-icon mui-icon-close" @click="closeModel"></span>
         </div>
       </div>
       <div class="middle">
         <div class="m1">
           <p>颜色分类</p>
           <span :class="{hover:changeColor==index}" 
           @click="change(index)"
           v-for="(c,index) in productColor">{{c.c}}</span>
         </div>
         <div style="height:10px;"></div>
         <div class="m1">
           <p>机身内存</p>
            <span :class="{hover:changeColor1==index}" 
            @click="change1(index)"
            v-for="(m,index) in memory">{{m.m}}</span>
         </div>
         <div class="m2">
           <span>购买数量</span>
           <span class="icon" @click="reduce">-</span>
           <span>{{count}}</span>
           <span class="icon" @click="add">+</span>
         </div>
       </div>
       <div class="btn1" @click="tishi">确定</div>
    </mt-popup>
    </div>
  </div>
</template>

<script>
import { Toast } from 'mint-ui';
import { Indicator } from 'mint-ui';
import { Popup } from 'mint-ui';
  export default{
    data:function(){
      return {
       bannerImg:[],
       popupVisible:false,
      productColor:[{c:'蓝色'},{c:'白色'}],
      memory:[{m:'120G'},{m:'60G'}],
      changeColor:0,
      changeColor1:0,
      count:1
      }
    },
    created(){
      this.getImg();
    },
    methods:{
      getImg(){
        this.bannerImg=[
          {imgUrl:require('../../assets/img/xj3.jpg')},
          {imgUrl:require('../../assets/img/xj3.jpg')},
          {imgUrl:require('../../assets/img/xj3.jpg')}
        ]
      },
      handleClick() {
        this.popupVisible = true;
        },
      closeModel(){
        this.popupVisible = false;
      },
      change(index){
        this.changeColor=index;
      },
      change1(index){
        this.changeColor1=index;
      },
      reduce(){
        if(this.count==1){
          return;
        }
        this.count--;
      },
      add(){
        this.count++;
      },
      tishi(){
        this.closeModel();
       Toast({
         message: '添加成功',
         iconClass: 'icon icon-success',
        });
      },
      goBack(){
       this.$router.go(-1);
     },
     jiazai(){
       Indicator.open('加载中...')
       setTimeout(()=>{
         Indicator.close();
         this.$router.push('/pay')
       },300)
     }
    }
  }
</script>

<style scoped>
  .mint-swipe, .mint-swipe-items-wrap{
    height: 250px;
  }
  .top1{
   margin-top: 10px;
    width:100%;
    height: 40px;
  }
  .top1 .left{
    width: 79%;
    float: left;
    color: #414141;
    font-size: 14px;
    line-height:16px;
    padding-left: 5px
  }
  .top1 .right{
    float: left;
    width: 20%;
    font-size: .35rem;
    border-left: 1px solid #dfdfdf;
    text-align: center;
  }
  .top1 .right>p{
    color: #5b5f62;
    font-size: 12px;
    margin-bottom: 0px;
  }
  .mui-icon-extra-share:before{
    color: #5b5f62;
  }
  .mui-icon-extra{
    font-size: 16px;
  }
  .down p{
    float: left;
    width: 79%;
    padding-left: 5px;
    color:#f44623;
    font-size: 16px

  }
  .down span{
    font-size: 12px;
    color: #5b5f62;
    display: inline-block;
    text-align: center;
    width: 20%;
  }
  .container{
    background: #efeff4;
    height: 162px;
    width: 100%;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .container .item{
    height: 50px;
    background: #fff;
    border-top:1px solid #dfdfdf;
    border-bottom: 1px solid #dfdfdf;
    margin-bottom: 10px;
  }
  .container .item a>span:first-child{
    color: #333333;
    padding-left: 5%;
    line-height: 50px;
    display: inline-block;
    width: 85%;
  }
  .mui-icon-forward:before{
    color: #5b5f62;
  }
  .btn{
    margin-bottom: 50px;
    height: 45px;
  }
  .btn>ul>li{
    float: left;
  }
  .btn>ul .left_icon{
    width: 15%;
    text-align: center;
    border-right: 1px solid #e6e6e6;
   
  }
  .btn>ul .left_icon p{
    color: #5b5f62;
    font-size: 12px;
    margin-top: -2px;
  }
  .btn>ul .right_btn{
    width: 35%;
  }
  span.mui-icon-home-filled:before,span.mui-icon-chat:before{
    color: #5b5f62;
    font-size: 16px;
  }
  span.mui-icon-chat:before{
    font-size: 12px;
  }
  .btn>ul .right_btn span{
    display: inline-block;
    width: 100%;
    color: #ffffff;
    height: 45px;
    line-height: 45px;
    text-align: center;
  }
  .btn>ul .right_btn .cart{
    background-color: #ff9100;
    
  }
  .btn>ul .right_btn .pay{
    background-color: #f44623;
  }
 

  /*购物车弹出*/
 .model{
    width: 100%;
  }
  .model .top .top1,.model .top .top2,.model .top .top3{
    float: left;
    height: 110px;
  }
  .model .top .top1{
    width: 25%;
    margin-left: 3%;
  }
  .model .top .top1 img{
    width:100px;
    height: 100px;
    margin-top: -20px;
  }
  .model .top .top2{
    width: 60%;
    padding-left: 5%;
  }
  .model .top .top2 p{
    font-size: 16px;
  }
  .model .top .top2 p:last-child{
    color: #f44623;
  }
  .model .top .top3 .mui-icon{
   font-size: 26px;
  }
  .middle {
    margin-top: 10px;
  }
  .middle .m1{
    width:90%;
    margin-left: 5%;
    margin-right: 5%;
    border-bottom: 1px solid #dfdfdf;
    height: 90px;
  }
  .middle .m1 p{
    font-size: 18px;
  }
  .middle .m1 span{
    display:inline-block;
    width: 80px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    background-color: #f5f5f5;
    margin-right: 5px;
    font-size: 14px;
  }
  .middle .m1 span.hover{
    color: #fff;
    background-color: #9dc1e5;
  }
  .middle .m2{
    width:90%;
    margin-left: 5%;
    margin-right: 5%;
    height: 60px;
    line-height: 60px;
  }
  .middle .m2 span:first-child{
    width: 70%;
    display: inline-block;
  }
  .middle .m2 .icon{
    display: inline-block;
    height: 30px;
    width: 30px;
    background-color: #f5f5f5;
    line-height: 30px;
    text-align: center;
    font-size: 20px;
    color:#5b5f62
  }
  .btn1{
    width: 100%;
    height: 50px;
    color: #ffffff;
    font-size: 18px;
    line-height: 50px;
    background-color: #9dc1e5;
    text-align: center;
  }
</style>